/*********************\
* Author:Dzlua
* QQ:505544956
* Time:2017/04/07
\**********************/
#include "../common.h"
#include <iostream>
using namespace std;

int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
//#ifdef _DEBUG
    ::setlocale(LC_ALL, "chs");
    ::AllocConsole();
    ::SetConsoleTitle(_T("test lua output"));
    ::freopen("CONOUT$","w+t",stdout);
    ::freopen("CONIN$","r+t",stdin);
    ::freopen("CONOUT$","w+t",stderr);
    printf("--------�������� %s ʱ�� %s--------\n",__DATE__,__TIME__);
//#endif

    SDPtr->Init(/*hInstance*/);
    
    SDPtr->SetResourcePath(SDPtr->GetInstancePath() + _T("skin/testlua"));

    SDLuaScript* script = new SDLuaScript;
    SDPtr->SetStript(script, true);
    if (script->DoFile(SDPtr->GetInstancePath() + _T("lua/testlua/main.lua"))) {
        SDPtr->MessageLoop();
    } else {
        SDTString err = SDPtr->GetError();
        cout << SDConvert::TToA(err) << endl;
        MessageBox(NULL, err.c_str(), _T("lua error"), MB_OK);
    }

    system("pause");

    SDPtr->Quit();
    return 0;
}